#! /usr/bin/env python
#*
#*  Copyright (c) 2010, Eric Perko
#*  All rights reserved.
#*
#*  Redistribution and use in source and binary forms, with or without
#*  modification, are permitted provided that the following conditions
#*  are met:
#*
#*   * Redistributions of source code must retain the above copyright
#*     notice, this list of conditions and the following disclaimer.
#*   * Redistributions in binary form must reproduce the above
#*     copyright notice, this list of conditions and the following
#*     disclaimer in the documentation and/or other materials provided
#*     with the distribution.
#*   * Neither the name of the author nor the names of other
#*     contributors may be used to endorse or promote products derived
#*     from this software without specific prior written permission.
#*
#*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
#*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
#*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
#*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
#*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
#*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
#*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
#*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
#*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#*  POSSIBILITY OF SUCH DAMAGE.
#***********************************************************

# uvc_cam camera dynamic configuration

PACKAGE='uvc_cam'
import roslib; roslib.load_manifest(PACKAGE)

from dynamic_reconfigure.parameter_generator import *
from driver_base.msg import SensorLevels

gen = ParameterGenerator()

format_rgb = gen.const("MODE_RGB", int_t, 1, "Capture in RGB mode")
format_yuyv = gen.const("MODE_YUYV", int_t, 2, "Capture in YUYV mode")
format_mjpg = gen.const("MODE_MJPEG", int_t, 3, "Capture in MJPG mode")
format_mode_enum = gen.enum([format_rgb, format_yuyv, format_mjpg], "The camera capture format")

#       Name, Type, Reconfiguration level, Description, Default, Min, Max

gen.add("camera_name", str_t, SensorLevels.RECONFIGURE_CLOSE,
		"The name of the camera (serial number or otherwise)", "camera")
		
gen.add("device", str_t, SensorLevels.RECONFIGURE_CLOSE,
		"The v4l2 device path", "/dev/video0")

gen.add("format_mode", int_t, SensorLevels.RECONFIGURE_CLOSE, "The format the camera should be captured in", 1, 1, 3, edit_method = format_mode_enum)

gen.add("width", int_t, SensorLevels.RECONFIGURE_CLOSE,
        "Width of image in pixels.", 640)
        
gen.add("height", int_t, SensorLevels.RECONFIGURE_CLOSE,
		"Height of image in pixels.", 480)
		
gen.add("frame_id", str_t, SensorLevels.RECONFIGURE_CLOSE,
        "ROS tf frame of reference, resolved with tf_prefix unless absolute.",
        "camera")

gen.add("frame_rate", double_t, SensorLevels.RECONFIGURE_CLOSE,
        "Camera speed (frames per second).", 15.0, 1.875, 240.0)

gen.add("camera_info_url", str_t, SensorLevels.RECONFIGURE_RUNNING,
        "Camera calibration URL for this video_mode (uncalibrated if null).",
        "")

gen.add("absolute_exposure", int_t, SensorLevels.RECONFIGURE_RUNNING,
        "absolute exposure of the camera",
        2089)

gen.add("exposure", int_t, SensorLevels.RECONFIGURE_RUNNING,
        "menu selection for the exposure mode of the camera",
        1)
        
gen.add("sharpness", int_t, SensorLevels.RECONFIGURE_RUNNING,
        "sharpness of the camera image",
        142)
        
gen.add("power_line_frequency", int_t, SensorLevels.RECONFIGURE_RUNNING,
        "menu selection for the power line frequency",
        0)
        
gen.add("white_balance_temperature", bool_t, SensorLevels.RECONFIGURE_RUNNING,
        "white balance of the camera",
        True)
        
gen.add("gain", int_t, SensorLevels.RECONFIGURE_RUNNING,
        "gain of the camera",
        82)
        
gen.add("saturation", int_t, SensorLevels.RECONFIGURE_RUNNING,
        "saturation of the camera",
        50)
        
gen.add("contrast", int_t, SensorLevels.RECONFIGURE_RUNNING,
        "contrast of the camera",
        50)
         
gen.add("brightness", int_t, SensorLevels.RECONFIGURE_RUNNING,
        "brightness of the camera",
        66)

exit(gen.generate(PACKAGE, "uvc_cam_node", "UVCCam"))
